home *** CD-ROM | disk | FTP | other *** search
- /**\
- |**| =====================================================================
- |**|
- |**| FILENAME
- |**| TestCubics.c
- |**|
- |**| DESCRIPTION
- |**| This program demonstrates Cubic splines in Quickdraw GX.
- |**|
- |**| COPYRIGHT
- |**| ©1992-1996 Copyright Apple Computer, Inc.
- |**| All rights reserved.
- |**|
- |**| Change History:
- |**|
- |**| 4/96 cnn Changed fixed to Fixed. Updated the header
- |**| filename, description, and copyright.
- |**| Added name for parameter cursFlag in DoContentClick.
- |**| Changed (temppoint != where) to
- |**| ((temppoint.x != where->x) || (temppoint.y != where->y)).
- |**| Changed tempstring from a Str255 to a char array.
- |**| Added definition of "qd" with #if conditional.
- |**| Changed mClip to mPoints. Removed non-functional
- |**| "Open..." and "Save As..." menu items from File menu.
- |**|
- |**| =====================================================================
- \**/
-
- #include "TestCubics.h"
- #include <Strings.h>
-
- Cursor gHandCurs;
- Boolean gPolyMode;
- short gFileRef;
- long gcount = 0;
- long gticks = 0;
-
- long gpointcount = 0;
- long gquadcount = 0;
-
- long geindx = 2;
- extended gerror = 0.25;
-
- short gcurrent = 0;
-
- gxGraphicsClient gClient;
-
- #if GENERATINGCFM
- QDGlobals qd;
- #else
- #ifndef SYMANTEC_C
- #ifndef SYMANTEC_CPLUS
- #define __MPW_ONLY__
- #endif
- #endif
-
- #if defined (__SC__) && defined (__MPW_ONLY__)
- QDGlobals qd;
- #endif
-
- #undef __MPW_ONLY__
- #endif
-
- #pragma segment Main
- void main(void)
- {
- Initialize();
- EventLoop();
- }
-
- #pragma segment Main
- void EventLoop(void)
- {
- Boolean gotEvent;
- EventRecord event;
- short cursFlag;
-
- cursFlag = kCursInit;
-
- do
- {
- SystemTask();
- gotEvent = GetNextEvent(everyEvent,&event);
-
- if(gotEvent)
- {
- AdjustCursor(&event,&cursFlag);
- DoEvent(&event,&cursFlag);
- }
- else
- {
- AdjustCursor(&event,&cursFlag);
- /* do Idle stuff */
- }
- }while(true);
- }
-
- #pragma segment Main
- void DoEvent(EventRecord *event,
- short *cursFlag)
- {
- short part;
- WindowPtr window;
- char key;
-
- switch(event->what)
- {
- case nullEvent:
- AdjustCursor(event,cursFlag);
- break;
-
- case mouseDown:
- part = FindWindow(event->where,&window);
-
- switch(part)
- {
- case inMenuBar:
- AdjustMenus();
- DoMenuCommand(MenuSelect(event->where));
- break;
-
- case inSysWindow:
- SystemClick(event,window);
- break;
-
- case inContent:
- if(window!=FrontWindow())
- SelectWindow(window);
- else
- DoContentClick(window,event,cursFlag);
- break;
-
- case inDrag:
- DragWindow(window,event->where,&qd.screenBits.bounds);
- break;
-
- case inGoAway:
- if(TrackGoAway(window,event->where))
- DoCloseWindow(window); // Quit
- break;
-
- case inGrow:
- DoGrowWindow(window,event);
- break;
-
- case inZoomIn:
- case inZoomOut:
- if(TrackBox(window,event->where,part))
- DoZoomWindow(window,part);
- break;
- }
- break;
-
- case keyDown:
- key = event->message & charCodeMask;
- if(event->modifiers & cmdKey)
- {
- AdjustMenus();
- DoMenuCommand(MenuKey(key));
- }
- break;
-
- case activateEvt:
- break;
-
- case updateEvt:
- DoUpdate((WindowPtr) event->message);
- break;
-
- }
- }
-
- #pragma segment Main
- void AdjustCursor(EventRecord *event,
- short *cursFlag)
- {
- WindowPtr window;
- RgnHandle contRgn;
- RgnHandle growRgn;
- Rect growRect;
-
- window = FrontWindow();
- if(!IsDAWindow(window))
- {
- contRgn = NewRgn();
- growRgn = NewRgn();
-
- if(IsAppWindow(window))
- {
- CopyRgn(((WindowPeek)window)->contRgn,contRgn);
-
- growRect = (*((WindowPeek)window)->contRgn)->rgnBBox;
- growRect.top = growRect.bottom - kGrowBHeight;
- growRect.left = growRect.right - kGrowBWidth;
-
- SetPort(window);
-
- RectRgn(growRgn,&growRect);
-
- SetOrigin(-window->portBits.bounds.left,
- -window->portBits.bounds.top);
-
- DiffRgn(contRgn,growRgn,contRgn);
- SetOrigin(0,0);
- }
-
- if(PtInRgn(event->where,contRgn))
- {
- if(event->modifiers & optionKey)
- {
- // do the hand
- if(*cursFlag != kCursHand)
- {
- SetCursor(&gHandCurs);
- *cursFlag = kCursHand;
- }
- }
- else
- {
- if(*cursFlag != kCursCross)
- {
- SetCursor(*GetCursor(crossCursor));
- *cursFlag = kCursCross;
- }
- }
- }
- else
- {
- SetCursor(&qd.arrow);
- *cursFlag = kCursArrow;
- }
- DisposeRgn(growRgn);
- DisposeRgn(contRgn);
- }
- else
- {
- if(*cursFlag != kCursArrow)
- {
- SetCursor(&qd.arrow);
- *cursFlag = kCursArrow;
- }
- }
- }
- #pragma segment Main
- void DoGrowWindow(WindowPtr window,
- EventRecord *event)
- {
- long growResult;
- Rect tempRect;
- DocumentPeek doc;
-
- tempRect = qd.screenBits.bounds;
- tempRect.left = kMinDocSize;
- tempRect.top = kMinDocSize;
-
- growResult = GrowWindow(window, event->where, &tempRect);
-
- if (growResult!=0)
- {
- doc = (DocumentPeek) window;
- SizeWindow(window, LoWrd(growResult), HiWrd(growResult), true);
- ResizeWindow(window);
- }
- }
- #pragma segment Main
- void DoZoomWindow(WindowPtr window,
- short part)
- {
- ZoomWindow(window, part, window == FrontWindow());
- ResizeWindow(window);
- }
-
- #pragma segment Main
- void ResizeWindow(WindowPtr window)
- {
- InvalRect(&window->portRect);
- }
-
- #pragma segment Main
- void DoUpdate(WindowPtr window)
- {
- if (IsAppWindow(window))
- {
- BeginUpdate(window);
- if (! EmptyRgn(window->visRgn))
- DrawWindow(window);
- EndUpdate(window);
- }
- }
-
- #pragma segment Main
- void DoContentClick(WindowPtr window,
- EventRecord *event,
- short *cursFlag)
- {
- DocumentPeek doc;
-
- Point orgPoint;
-
- long pinVal;
- Rect pinRect;
- Rect limitRect;
-
- long indx;
-
- SetWorkRect(window,&pinRect,&limitRect);
-
- orgPoint = event->where;
- GlobalToLocal(&orgPoint); // now in local coordinates
-
- pinVal = PinRect(&pinRect,orgPoint);
- orgPoint.h = LoWrd(pinVal);
- orgPoint.v = HiWrd(pinVal);
-
- // convert the gxPoint to fixed gxPoint units and check to see if it
- // is hitting any of the handles off the cubic and re-draw them
-
- doc = (DocumentPeek) window;
-
- // check to see if we have clicked on one of the control points
-
- {
- gxPoint *dataPtr;
-
- Boolean found = false;
-
- gcurrent = (-1); // this is to know if we clicked on nothing
-
- HLockHi((Handle) doc->data );
-
- dataPtr =(gxPoint *) *doc->data;
-
- for( indx = 0; indx < gpointcount; ++indx )
- {
- gcurrent = indx;
-
- if( DoCubicDrag( dataPtr, orgPoint, doc ) )
- {
- found = true;
- break;
- }
- }
-
- HUnlock((Handle) doc->data );
-
- if( found == false )
- {
- Handle dataHdl = (Handle) doc->data;
-
- // ## for now we just add one gxPoint
-
- SetHandleSize( dataHdl, ( doc->count + 1 ) * sizeof( gxPoint ) );
-
- if( MemError() != noErr ) goto FailedToAddPoint;
- // now store the gxPoint
-
- {
- gxPoint *dataPtr = & (*(gxPoint **)dataHdl)[ doc->count ];
-
- dataPtr->x = ff( orgPoint.h );
- dataPtr->y = ff( orgPoint.v );
-
- DrawControlHandle( dataPtr );
- }
-
- // increase the count
-
- doc->count += 1;
- gpointcount = doc->count;
- gcurrent = ( ( gpointcount - 1 ) / 3 ) * 3;
-
- DrawCubicNumbers( doc );
-
- // if this makes an entirely new cubic then draw the gxCurve
-
- if( ( doc->count == 4 ) || ( ( 4 < doc->count ) && ( ( doc->count - 4 ) % 3 ) == 0 ) )
- DrawCurves( doc->data );
- }
- }
-
- FailedToAddPoint:;
-
- }
-
- #pragma segment Main
-
- short DoCubicDrag( gxPoint *dataPtr, Point start, DocumentPeek doc )
- {
- gxRectangle box;
-
- gxPoint *where;
-
- where = & dataPtr[ gcurrent ];
-
- // first check to see if the start gxPoint is near the handle
-
- box.left = ff( start.h - 2 );
- box.top = ff( start.v - 2 );
- box.right = ff( start.h + 2 );
- box.bottom = ff( start.v + 2 );
-
- if( GXTouchesRectanglePoint( &box, where ) != false )
- {
- gxShape sh;
- gxShape sh2;
-
- gxColor tempcolor;
- gxColor tempcolor2;
-
- long cubeindx;
-
- cubeindx = gcurrent & ~0x3;
-
- if( gcurrent <= 0 )
- cubeindx = 0;
- else
- cubeindx = ( ( gcurrent - 1 ) / 3 ) * 3;
-
- if( gpointcount < ( cubeindx + 3 ) ) return( false );
-
- tempcolor.space = gxGraySpace;
- tempcolor.element.gray = 0;
- tempcolor.profile = nil;
-
- tempcolor2.space = gxGraySpace;
- tempcolor2.element.gray = 0xFFFF;
- tempcolor2.profile = nil;
-
- EraseRect(& ((WindowPtr)doc)->portRect );
- sh = NewCubic((cubic *) &dataPtr[ cubeindx ] ); GXSetShapeFill( sh, gxOpenFrameFill );
- GXDrawShape( sh );
- GXDisposeShape( sh );
-
- do
- {
- gxPoint temppoint;
- gxPoint savepoint;
-
- GXGetViewPortMouse( doc->vp, &temppoint );
-
- GXIgnoreGraphicsNotice( color_already_set );
- GXIgnoreGraphicsNotice( halftone_already_set );
-
- if( (temppoint.x != where->x) || (temppoint.y != where->y) )
- {
- savepoint = *where;
-
- *where = temppoint;
-
- // draw the new cubic in xor mode
-
- sh = NewCubic((cubic *) &dataPtr[ cubeindx ] ); GXSetShapeFill( sh, gxOpenFrameFill );
-
- SetShapeFastXorTransfer( sh, &tempcolor2, &tempcolor );
-
- // erase the previous cubic by drawing in xor mode
-
- *where = savepoint;
-
- sh2 = NewCubic((cubic *) &dataPtr[ cubeindx ] ); GXSetShapeFill( sh2, gxOpenFrameFill );
- SetShapeFastXorTransfer( sh2, &tempcolor, &tempcolor2 );
-
- GXDrawShape( sh ); // erase first
- GXDrawShape( sh2 ); // draw now
-
- GXDisposeShape( sh );
- GXDisposeShape( sh2 );
-
- *where = temppoint;
-
- DrawCubicNumbers( doc );
- }
-
- GXPopGraphicsNotice();
- GXPopGraphicsNotice();
-
- } while( StillDown() );
-
- InvalRect(& ((WindowPtr)doc)->portRect );
-
- return( true );
- }
- else
- {
- return( false );
- }
- }
-
- #pragma segment Main
- void SetWorkRect(WindowPtr window,
- Rect *pinRect,
- Rect *limitRect)
- {
- SetPort(window);
- *limitRect = (*((WindowPeek) window)->contRgn)->rgnBBox;
- GlobalToLocal(&TopLeft(*limitRect));
- GlobalToLocal(&BotRight(*limitRect));
-
- *pinRect = *limitRect;
-
- InsetRect(limitRect,-5,-5);
- InsetRect(pinRect,5,5);
- return;
- }
- #pragma segment Main
- void Initialize( void )
- {
- Handle menuBar;
- Ptr storage;
- WindowPtr window;
- DocumentPeek doc;
- CursHandle hCurs;
-
- MaxApplZone();
- MoreMasters(); MoreMasters(); MoreMasters();
-
- gClient = GXNewGraphicsClient(nil, 800L * 1024L, 0);
- GXEnterGraphics();
-
- SetGraphicsLibraryErrors();
- SetGraphicsLibraryNotices();
-
- InitGraf((Ptr) &qd.thePort);
- InitFonts();
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(nil);
- InitCursor();
-
- menuBar = GetNewMBar(rMenuBar);
-
- SetMenuBar(menuBar);
- DisposHandle(menuBar);
- AddResMenu(GetMHandle(mApple), 'DRVR');
- DrawMenuBar();
-
- storage = NewPtr(sizeof( DocumentRecord ));
-
- if ( storage != nil )
- {
- window = GetNewWindow(rDocWindow, storage, (WindowPtr) -1);
-
- doc = (DocumentPeek) window;
- doc->vp = GXNewWindowViewPort( window );
-
- GXIgnoreGraphicsNotice(transform_already_set);
- SetDefaultViewPort( doc->vp );
- GXPopGraphicsNotice();
-
- // gxInitialize all of the fields that have to do with the document
-
- doc->count = 0;
- doc->data = (gxPoint **) NewHandle( 0 ); // there are no points
-
- ShowWindow(window);
- }
- else
- DisposPtr(storage); /* get rid of the storage if it is never used */
-
- hCurs = (CursHandle) GetResource('CURS',rHandCurs);
-
- if(hCurs != nil)
- {
- gHandCurs = **hCurs;
- ReleaseResource((Handle) hCurs);
- }
-
- gPolyMode = false;
- }
- #pragma segment Main
- void DrawControlHandle( gxPoint *where )
- {
- gxRectangle box;
- gxShape sh;
-
- box.left = where->x - ff( 2 );
- box.top = where->y - ff( 2 );
- box.right = where->x + ff( 2 );
- box.bottom = where->y + ff( 2 );
-
- sh = GXNewRectangle( &box );
-
- GXDrawShape( sh );
- GXDisposeShape( sh );
- }
-
- void DrawCubicNumbers( DocumentPeek doc )
- {
-
- char tempstring [256];
-
- Rect erasebox = { 0, 0, 26, 170 };
-
- TextFont( geneva );
- TextSize( 9 );
-
- // now calculate the number of quadratics that are needed to approximate this cubic
-
- sprintf( tempstring, "ticks: %d count: %d", gticks, gpointcount );
-
- EraseRect( &erasebox );
- MoveTo( 5, 24 );
- DrawString( c2pstr( tempstring ) );
-
- // we also need to calculate the error for the current cubic
-
- {
- long cubeindx;
- extended ax, ay, a, n;
- extended curveerror;
-
- long count;
- gxPoint *dataPtr;
-
- if( gcurrent <= 0 )
- cubeindx = 0;
- else
- cubeindx = ( ( gcurrent - 1 ) / 3 ) * 3;
-
- if( gpointcount < ( cubeindx + 4 ) ) goto NotDoneYet;
-
- dataPtr = *(doc->data);
- dataPtr = & dataPtr[ cubeindx ];
-
- ax = Fix2X( ( dataPtr[ 3 ].x - dataPtr[ 0 ].x ) + 3 * ( dataPtr[ 1 ].x - dataPtr[ 2 ].x ) );
- ay = Fix2X( ( dataPtr[ 3 ].y - dataPtr[ 0 ].y ) + 3 * ( dataPtr[ 1 ].y - dataPtr[ 2 ].y ) );
-
- a = hypot( ax, ay );
-
- n = power( ( a / ( 20.0 * gerror ) ), 1.0 / 3.0 );
- count = ceil( n );
-
- curveerror = a / ( 20 * count * count * count );
-
- sprintf( tempstring, "error: %.4lf quads: %d", curveerror, count );
- MoveTo( 5, 12 );
- DrawString( c2pstr( tempstring ) );
- }
- NotDoneYet:;
- }
-
- void DrawCubicControl( gxShape sh ) // given a cubic it shows where the control points are
- {
- short count;
- short indx;
-
- Fixed cross[ 11 ];
- gxPoint where;
-
- gxShape sh2;
-
- if( GXCountShapeContours( sh ) == 1 )
- {
- count = GXCountShapePoints( sh, 1 ) - 2;
-
- cross[ 0 ] = 2;
- cross[ 1 ] = 2;
- cross[ 6 ] = 2;
-
- for( indx = 1; 0 < count; --count )
- {
- GetShapeIndexPoint( sh, ++indx, &where );
-
- cross[ 2 ] = where.x - ff( 3 );
- cross[ 3 ] = where.y - ff( 3 );
- cross[ 4 ] = where.x + ff( 3 );
- cross[ 5 ] = where.y + ff( 3 );
- cross[ 7 ] = where.x + ff( 3 );
- cross[ 8 ] = where.y - ff( 3 );
- cross[ 9 ] = where.x - ff( 3 );
- cross[ 10 ] = where.y + ff( 3 );
-
- sh2 = GXNewPolygons((gxPolygons *) & cross[ 0 ] );
- GXSetShapeFill( sh2, gxOpenFrameFill );
- GXDrawShape( sh2 );
- GXDisposeShape( sh2 );
- }
- }
- }
-
- #pragma segment Main
- void DrawWindow(WindowPtr window)
- {
- DocumentPeek doc;
- PenState pen;
-
- doc = (DocumentPeek) window;
-
- SetPort(window);
- GetPenState(&pen);
-
- PenNormal();
- EraseRect(&window->portRect);
-
- gticks = TickCount();
-
- DrawCurves( doc->data );
- gticks = TickCount() - gticks;
-
- DrawCubicNumbers( doc );
-
- // we now draw the cubic and its control points
-
- ForeColor(blackColor);
- DrawMyGrow(window);
-
- SetPenState(&pen);
- return;
- }
-
- void DrawCurves( gxPoint **data )
- {
- long indx;
- gxColor tempcolor;
- gxShape sh;
-
- gxPoint *dataPtr;
-
- tempcolor.space = gxRGBSpace;
- tempcolor.profile = nil;
- tempcolor.element.rgb.red = 0xFFFF;
- tempcolor.element.rgb.green = tempcolor.element.rgb.blue = 0;
-
- HLock((Handle) data );
-
- dataPtr = *data;
-
- for( indx = 4; indx <= gpointcount; indx += 3 )
- {
- cubic *cube = (cubic *) & dataPtr[ indx - 4 ];
-
- sh = NewCubic( cube ); // first draw the reference cubic (in red)
- GXSetShapeFill( sh, gxOpenFrameFill );
- GXSetShapeColor( sh, &tempcolor );
- GXDrawShape( sh );
- GXDisposeShape( sh );
-
- sh = NewCubic2( cube, gcount ); GXSetShapeFill( sh, gxOpenFrameFill );
-
- GXDrawShape( sh );
- DrawCubicControl( sh );
- GXDisposeShape( sh );
-
- DrawControlHandle( &cube->a );
- DrawControlHandle( &cube->b );
- DrawControlHandle( &cube->c );
- DrawControlHandle( &cube->d );
- }
-
- HUnlock((Handle) data );
- }
-
- #pragma segment Main
- void DrawMyGrow(WindowPtr window)
- {
- Rect tempRect;
- Rect drawRect;
- PenState pen;
-
- SetPort(window);
- GetPenState(&pen);
- PenNormal();
-
- tempRect = (*((WindowPeek) window)->contRgn)->rgnBBox;
-
- drawRect.top = tempRect.bottom - 16;
- drawRect.left = tempRect.right -16;
- drawRect.bottom = tempRect.bottom;
- drawRect.right = tempRect.right;
-
- GlobalToLocal(&TopLeft(drawRect));
- GlobalToLocal(&BotRight(drawRect));
-
- EraseRect(&drawRect);
- FrameRect(&drawRect);
-
- drawRect.right -= 2;
- drawRect.bottom -= 2;
- drawRect.left += 5;
- drawRect.top += 5;
-
- FrameRect(&drawRect);
-
- drawRect.right -= 4;
- drawRect.bottom -= 4;
- drawRect.top -= 2;
- drawRect.left -= 2;
-
- EraseRect(&drawRect);
- FrameRect(&drawRect);
-
- SetPenState(&pen);
- return;
- }
-
-
- #pragma segment Main
- void AdjustMenus( void )
- {
- WindowPtr window;
- MenuHandle menu;
- Boolean undo;
-
- window = FrontWindow();
-
- menu = GetMHandle(mEdit);
- undo = false;
-
- if ( IsDAWindow(window) )
- undo = true;
-
- if ( undo )
- {
- EnableItem(menu, iUndo);
- EnableItem(menu, iCut);
- EnableItem(menu, iCopy);
- EnableItem(menu, iPaste);
- EnableItem(menu, iClear);
- }
- else
- {
- DisableItem(menu, iUndo);
- DisableItem(menu, iCut);
- DisableItem(menu, iCopy);
- DisableItem(menu, iPaste);
- DisableItem(menu, iClear);
- }
-
- return;
- }
-
- #pragma segment Main
- void DoMenuCommand(long menuResult)
- {
- short menuID; /* the resource ID of the selected menu */
- short menuItem; /* the item number of the selected menu */
- short itemHit;
- Str255 daName;
- short daRefNum;
- WindowPtr window;
-
- window = FrontWindow();
-
- menuID = HiWrd(menuResult); /* use macros for efficiency to... */
- menuItem = LoWrd(menuResult); /* get menu item number and menu number */
-
- switch ( menuID )
- {
- case mApple:
- switch ( menuItem )
- {
- case iAbout:
- itemHit = Alert(rAboutAlert, nil);
- break;
- default:
- GetItem(GetMHandle(mApple), menuItem, daName);
- daRefNum = OpenDeskAcc(daName);
- break;
- }
- break;
-
- case mFile:
- if( menuItem == iQuit )
- ExitApplication( window );
- break;
-
- case mEdit:
- SystemEdit(menuItem-1);
- break;
-
- case mPoints:
- CheckItem( GetMHandle(mPoints), gcount + 1, false );
- CheckItem( GetMHandle(mPoints), menuItem, true );
- gcount = menuItem - 1;
- InvalRect(&window->portRect);
- break;
-
- case mError:
- {
- if( menuItem != geindx )
- {
- CheckItem( GetMHandle(mError), geindx, false );
- CheckItem( GetMHandle(mError), menuItem, true );
- geindx = menuItem;
- InvalRect(&window->portRect);
-
- switch( menuItem )
- {
- case iOneTenth:
- gerror = 0.01;
- break;
- case iOneQuater:
- gerror = 0.25;
- break;
- case iOneHalf:
- gerror = 0.5;
- break;
- case iThreeQuaters:
- gerror = 0.75;
- break;
- case iOne:
- gerror = 1.0;
- break;
- case iTwo:
- gerror = 2.0;
- break;
- case iFour:
- gerror = 4.0;
- break;
- case iEight:
- gerror = 8.0;
- break;
- }
- }
- }
- break;
- }
- HiliteMenu(0); /* unhighlight what MenuSelect (or MenuKey) hilited */
- }
-
- #pragma segment Main
- void DoCloseWindow(WindowPtr window)
- {
- if ( IsDAWindow(window) )
- CloseDeskAcc(((WindowPeek) window)->windowKind);
- else if ( IsAppWindow(window) )
- ExitApplication( window );
- }
-
- #pragma segment Main
- Boolean IsAppWindow(WindowPtr window)
- {
- short windowKind;
-
- if ( window == nil )
- return false;
- else { /* application windows have windowKinds >= userKind (8) or dialogKind (2) */
- windowKind = ((WindowPeek) window)->windowKind;
- return (windowKind >= userKind) || (windowKind == dialogKind);
- }
- }
-
- #pragma segment Main
- Boolean IsDAWindow(WindowPtr window)
- {
- if ( window == nil )
- return false;
- else /* DA windows have negative windowKinds */
- return ((WindowPeek) window)->windowKind < 0;
- }
-
-
- void ExitApplication( WindowPtr window )
- {
- DisposeWindow( window );
- GXExitGraphics();
- GXDisposeGraphicsClient(gClient);
- ExitToShell();
- }
-
- long CountQuadratics( const cubic *cube )
- {
- long count;
- extended a, n;
-
- extended ax;
- extended ay;
-
- ax = Fix2X( - cube->a.x + 3 * cube->b.x - 3 * cube->c.x + cube->d.x );
- ay = Fix2X( - cube->a.y + 3 * cube->b.y - 3 * cube->c.y + cube->d.y );
-
- a = hypot( ax, ay );
-
- n = power( ( a / ( 20.0 * gerror ) ), 1.0 / 3.0 );
-
- count = ceil( n );
-
- if( count <= 0 )
- count += 1;
-
- return( count );
- }
-